package c.e.a.b.b;

import android.content.Context;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;
import android.util.Log;
import c.e.a.b.b.h.r;
import c.e.a.b.b.h.s;
import c.e.a.b.b.h.t;
import c.e.a.b.c.b;
import com.google.android.gms.common.zzk;
import com.google.android.gms.dynamite.DynamiteModule;
import com.google.android.gms.dynamite.DynamiteModule.a;
import java.util.Objects;
import javax.annotation.CheckReturnValue;

@CheckReturnValue
public final class n {
    public static volatile r a;
    public static final Object b = new Object();
    public static Context c;

    public static w a(String str, p pVar, boolean z, boolean z2) {
        try {
            if (a == null) {
                Objects.requireNonNull(c, "null reference");
                synchronized (b) {
                    if (a == null) {
                        r rVar;
                        IBinder b = DynamiteModule.c(c, DynamiteModule.j, "com.google.android.gms.googlecertificates").b("com.google.android.gms.common.GoogleCertificatesImpl");
                        int i = s.a;
                        if (b == null) {
                            rVar = null;
                        } else {
                            IInterface queryLocalInterface = b.queryLocalInterface("com.google.android.gms.common.internal.IGoogleCertificatesApi");
                            if (queryLocalInterface instanceof r) {
                                rVar = (r) queryLocalInterface;
                            } else {
                                rVar = new t(b);
                            }
                        }
                        a = rVar;
                    }
                }
            }
            Objects.requireNonNull(c, "null reference");
            try {
                if (a.p0(new zzk(str, pVar, z, z2), new b(c.getPackageManager()))) {
                    return w.d;
                }
                return new y(new o(z, str, pVar), null);
            } catch (RemoteException e) {
                Log.e("GoogleCertificates", "Failed to get Google certificates from remote", e);
                return new w(false, "module call", e);
            }
        } catch (a e2) {
            Log.e("GoogleCertificates", "Failed to get Google certificates from remote", e2);
            String str2 = "module init: ";
            String valueOf = String.valueOf(e2.getMessage());
            return new w(false, valueOf.length() != 0 ? str2.concat(valueOf) : new String(str2), e2);
        }
    }
}
